<?php
require_once 'classes/models/user.php';
class UserManager
{	
	public function auth($username, $password)
	{
		$db = database();
		$username = $db->sanitize($username);
		$password = $db->sanitize(md5($password));
		$query="SELECT * FROM users WHERE user_name = '$username' AND password = '$password'";

		$result = $db->get_row($query);

		if ($result)
		{
			$user = new User();
			$user->set_values($result);
			return $user;
		}
		else
		{
			return FALSE;
		}	
	}
	
	public function get_all()
	{
		$factory=new ModelFactory('User');
		return $factory->get_by_query('SELECT * FROM users');
	}
}
?>